-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove uses of FnBox #851
Remove uses of FnBox #851
Conversation
FnBox is unlikely to be ever stabilized, as unsized_locals fixes Box<dyn FnOnce()> to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hesitant to make this change when it had just become possible, but it seems to have been around a while now and isn't going away. It also might be worth waiting for rust-lang/rust#55431 which should let us do this without needing #[feature(unsized_locals)]
ourselves.
@@ -146,9 +145,10 @@ impl Fairing for AdHoc { | |||
fn on_attach(&self, rocket: Rocket) -> Result<Rocket, Rocket> { | |||
if let AdHocKind::Attach(ref mutex) = self.kind { | |||
let mut option = mutex.lock().expect("AdHoc::Attach lock"); | |||
option.take() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The extra let binding should be unnecessary -- just replace the line .call_box((rocket,))
with (rocket)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is unnecessary, however it looks ugly when having a function call in a multi-line chain like this.
Also, from what I understand, the plan in rustc is to deprecate and remove |
@xfix Where is that happening? We should ideally ask for that to be postponed. |
The last I checked:
So I don't think this will happen too quickly and we can probably wait a bit longer. I think the only reason not to merge this would be that |
Even then, if |
With rust-lang/rust#59500 merged, this should be possible without the feature gate once the next nightly is released. That would require increasing the minimum rustc version, more so than this PR already does. |
Merged in 7ab1c42. |
FnBox
is unlikely to be ever stabilized, asunsized_locals
fixesBox<dyn FnOnce()>
to work.